package com.love.driver.enums;

public enum DriverOrderEnum {

    // 待接单状态，值为1
    WAITING("1", "待接单"),
    // 已接单状态，值为2
    ACCEPTED("2", "已接单"),
    // 服务中状态，值为3
    SERVICE("3", "服务中"),
    // 已完成状态，值为4
    COMPLETED("4", "已完成"),
    // 取消状态，值为5
    CANCELED("5", "取消");

    private final String value;
    private final String description;

    DriverOrderEnum(String value, String description) {
        this.value = value;
        this.description = description;
    }

    // 获取状态数值
    public String getValue() {
        return value;
    }

    // 获取状态描述
    public String getDescription() {
        return description;
    }

    // 根据数值获取对应的枚举实例
    public static DriverOrderEnum getByValue(String value) {
        for (DriverOrderEnum status : values()) {
            if (status.value == value) {
                return status;
            }
        }
        throw new IllegalArgumentException("无效的订单状态值: " + value);
    }

    // 根据描述获取对应的枚举实例
    public static DriverOrderEnum getByDescription(String description) {
        for (DriverOrderEnum status : values()) {
            if (status.description.equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("无效的订单状态描述: " + description);
    }
}
